package com.zeltov.api;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zeltov.bo.Car;
import com.zeltov.dao.ICarDAO;

@Service("carFacade")
@Transactional
public class CarServiceFacadeImpl extends CarService{

	
	private ICarDAO carDao;

    @Autowired
	public void setCarDao(@Qualifier("carDaoSpring") ICarDAO carDao) {
		this.carDao = carDao;
	}

	public List<CarTO> getAllCars() {
		List<Car> allCarEOs = carDao.getAll();
		ArrayList<CarTO> carDtoList = new ArrayList<CarTO>();
		for (Car carEO : allCarEOs) {
			CarTO carDTO = new CarTO();
			copyProperties(carEO, carDTO);
			carDtoList.add(carDTO);
		}
		return carDtoList;	}
}
